package com.mondo.financialwallet.presentation.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import com.example.common.ui.BaseActivity;
import com.mondo.financialwallet.R;
import com.mondo.financialwallet.presentation.ui.adapter.FinancialAssetRecordAdapter;
import com.mondo.financialwallet.presentation.utils.ActivityTitleBarHelper;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 理财资产
 */
public class FinancialAssetsActivity extends BaseActivity {

    private static final String EXTRA_TOTAL_ASSET = "TOTAL_ASSET",
            EXTRA_YESTERDAY = "YESTERDAY";

    public static void launch(Context context, String totalAsset, String yesterdayEarnings) {
        context.startActivity(
                new Intent(context, FinancialAssetsActivity.class)
                        .putExtra(EXTRA_TOTAL_ASSET, totalAsset)
                        .putExtra(EXTRA_YESTERDAY, yesterdayEarnings)
        );
    }

    @Bind(R.id.financial_assets_text) TextView mFinancialAssetsText;
    @Bind(R.id.yesterday_earnings_text) TextView mYesterdayEarningsText;
    @Bind(R.id.financial_asset_record_list) RecyclerView mFinancialAssetRecordList;

    @Override
    protected void setStatusBar() {
        ActivityTitleBarHelper.setTransparentStatus(this);
    }

    @Override
    protected int getLayoutID() {
        return R.layout.activity_financial_assets;
    }

    @Override
    protected void initActions() {
        ActivityTitleBarHelper.init(this, R.string.title_financial_assets);

        // 收益数据
        String totalAsset = getIntent().getStringExtra(EXTRA_TOTAL_ASSET);
        String yesterdayEarnings = getIntent().getStringExtra(EXTRA_YESTERDAY);

        // 收益
        mFinancialAssetsText.setText(totalAsset);
        mYesterdayEarningsText.setText("+" + yesterdayEarnings);

        // 列表
        mFinancialAssetRecordList.setAdapter(
                FinancialAssetRecordAdapter.create(totalAsset, "+" + yesterdayEarnings));
    }

}
